<? 
$protectid="305"; 
include("../protect.php");

include_once("../../config.inc.php");

include_once(CFG_LIB_DIR.'mysqldb.inc.php');
$objDb = new mysqldb();

$id=$_GET['id'];
$page=$_POST["page"];
$sql="delete from `".con_strPREFIX."buycar` where ID=".$id;

if($action=="del"){
	if($id>0){
		$sql="delete from `".con_strPREFIX."buyorder` where ID=$id";
		$blnResult=$objDb->query($sql);
		if($blnResult){
			$sql="delete from `".con_strPREFIX."buycar` where OID=$id";
			$blnResult=$objDb->query($sql);
			echo "<script>alert('删除成功');location.href='index.php$page';</script>";
		}
		else{
			echo "<script>alert('删除失败，请重试');history.go(-1);</script>";
		}
		exit;
	}
	else{
		$sel=$_POST["sel"];
		if(!empty($sel)){
			foreach($sel as $v){
				if(empty($strID)){$strID = $v;}
				else{$strID .= ",".$v;}
			}
			$sql="delete from `".con_strPREFIX."order` where ID in($strID)";
			$blnResult=$objDb->query($sql);
			if($blnResult){
				$sql="delete from `".con_strPREFIX."order` where OID in($strID)";
				$blnResult=$objDb->query($sql);
				echo "<script>alert('删除成功');location.href='index.php$page';</script>";
			}
			else{
				echo "<script>alert('删除失败，请重试');history.go(-1);</script>";
			}
			exit;
		}
		else{
			echo "<script>alert('请选择要删除的记录');history.go(-1);</script>";
		}
	}
}
else if($_POST["action"]>=0 && $_POST["action"]<=6){
	$sel=$_POST["sel"];
	if(!empty($sel)){
		foreach($sel as $v){
			$sql="update `".con_strPREFIX."order` set State='$action' where ID ='$v'";
			$blnResult=$objDb->query($sql);
			if($blnResult){
				echo "<script>alert('操作成功');location.href='index.php$page';</script>";
			}
			else{
				echo "<script>alert('操作失败，请重试');history.go(-1);</script>";
			}
		}
	}
	else{
		echo "<script>alert('请选择要进行操作的记录');history.go(-1);</script>";
	}
}

?>